import { Application } from "mydog";

declare global {
  interface Rpc { connector: { main: Remote } }
}

export default class Remote {
  private app: Application;
  constructor(app: Application) {
    this.app = app;
  }

  public getOnlineNum() {
    return this.app.clientNum;
  }

  public bindRoomId(uid: number, roomId: number) {
    if (!!!uid || !!!roomId) { return; }

    const session = this.app.getSession(uid);
    session.set({ 'rid': roomId });
  }

  public unbindRoomId(uid: number) {
    if (!!!uid) { return; }

    const session = this.app.getSession(uid);
    session.set({ 'rid': null });
  }
}
